/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-12-26
 * Time: 16:20
 */
class OnlyOneException extends Exception {
    OnlyOneException(String s) {
        super(s);
    }
}

class NoOperandException extends Exception {
    NoOperandException(String s) {
        super(s);
    }
}

public class TestMyException {
    public static void main(String[] args) {
        try {
            if (args.length == 0) {
                throw new NoOperandException("没有输入参数！");
            } else if (args.length == 1) {
                throw new OnlyOneException("参数只有一个！");
            }

            int num1 = Integer.parseInt(args[0]);
            int num2 = Integer.parseInt(args[1]);
            int sum = num1 + num2;
            System.out.println("两个数的和为：" + sum);
        } catch (NoOperandException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            System.exit(1);
        } catch (OnlyOneException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            System.exit(1);
        }
    }
}